<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>日历演示</title>
<link href="css/date.css" rel="stylesheet" type="text/css">
<script language="javascript">

var PARAMS = { 
s_date:  new Date().getTime(),
e_date:  new Date().getTime(),
s2_date:  '',
e2_date:  ''
};

var VAR = {
	TODAY_TIME      :      new Date().getTime(),
	START_TIME      :      1296316800000
};
</script>
</head>
<body>

    
<div id="DateSelectBar" class="date-select-bar">
  <div class="l"> <a href="#00">今天</a><a href="#-1">昨天</a><a href="#-6">最近7天</a><a href="#-29">最近30天</a> </div>
  <div class="l">
    <input type="text" class="date" value="" readonly="readonly">
    <img src="img/btn_date.gif" />
    <label for="RadioDateBtn" class="dateCompare">
    <input type="checkbox" value="" id="RadioDateBtn" class="dateCompare" />
    与其他时间段对比 </label>
    <input type="text" class="date" value="" readonly="readonly">
    <img src="img/btn_date.gif" />
  </div>
</div>

<br />
起始日期&nbsp;&nbsp;<span id="d_start"></span>  &nbsp;&nbsp;&nbsp;结束日期&nbsp;&nbsp;<span id="d_end"></span> <br />
<br />
起始日期&nbsp;&nbsp;<span id="d2_start"></span> &nbsp;&nbsp;&nbsp;结束日期&nbsp;&nbsp;<span id="d2_end"></span><br />


<script language="javascript" src="js/date.js" type="text/javascript"></script>
<script language="javascript">

function writeDate(id, ts){
	if(ts !='' && ts > 0 ){
		document.getElementById(id).innerHTML = new Date(+ts).toLocaleString();
	}else{
		document.getElementById(id).innerHTML = '';
	}
}

(function () {
	writeDate('d_start',PARAMS.s_date);
	writeDate('d_end',PARAMS.e_date);
	writeDate('d2_start',PARAMS.s2_date);
	writeDate('d2_end',PARAMS.e2_date);

})();

var DC = new DateController({
	container: 'DateSelectBar',
    todayDate: new Date(+VAR.TODAY_TIME),
    firstDate: new Date(+VAR.START_TIME),
    startDate: new Date(+PARAMS.s_date),
    endDate: new Date(+PARAMS.e_date),
    otherStartDate: PARAMS.s2_date != "" ? new Date(+PARAMS.s2_date) : "",
    otherEndDate: PARAMS.s2_date != "" ? new Date(+PARAMS.e2_date) : "",
    onchange: dateOnchange
});

function dateOnchange(d) {

	//alert('日期被修改了, d = ' + d);

    PARAMS.s_date = this.startDate.getTime();
    PARAMS.e_date = this.endDate.getTime();
    var c = this.otherStartDate && this.otherStartDate.constructor == Date ? true : false;

    PARAMS.s2_date = c ? this.otherStartDate.getTime() : "";
    PARAMS.e2_date = c ? this.otherEndDate.getTime() : "";

	if(d == "submitDateSelect"){
		writeDate('d_start',PARAMS.s_date);
		writeDate('d_end',PARAMS.e_date);
		writeDate('d2_start',PARAMS.s2_date);
		writeDate('d2_end',PARAMS.e2_date);
	
	}else{
		writeDate('d_start',PARAMS.s_date);
		writeDate('d_end',PARAMS.e_date);
		writeDate('d2_start');
		writeDate('d2_end');
	}
}

</script>

</body>
</html>
